<script setup lang="ts">
//import { ref,computed  } from 'vue'
import * as store from './store.js'

import {
  useRouter,
  //  useRoute
} from 'vue-router'

const router = useRouter()
// const route = useRoute()

function requestGenerateNodeName() {
  parent.postMessage({ pluginMessage: { type: 'generate_node_name',value:{valueType:store.codeTemplateStore.value}  } }, '*')
}

function requestBack() {
  router.back();
}

</script>

<template>
  <div class="root">
    <div class="title_bar">
      <div class="back" @click="requestBack">
        <el-icon :size="20">
          <Back />
        </el-icon>
      </div>
      <div class="title">
        NodeName
      </div>
      <div class="back" />
    </div>

    <div class="content">
      <div class="ta_wrap">
        <textarea id="code_ta" style="width: 100%;resize: none;" :value="store.codeTemplateStore.value"></textarea>
      </div>
      <el-radio-group v-model="store.codeTemplateStore.value">
        <el-radio label="value" size="large">value</el-radio>
        <el-radio label="name" size="large">name</el-radio>
      </el-radio-group>
      <div class="actions">
        <button @click="requestGenerateNodeName">NodeName</button>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.root {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.title_bar {
  height: 36px;
  text-align: center;
  line-height: 35px;

  box-sizing: border-box;

  display: flex;
  flex-direction: row;

  .back {
    width: 36px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

  }

  .title {
    flex-shrink: 1;
    flex-grow: 1;
    flex-basis: auto;
  }
}

.content {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex-shrink: 1;
  flex-grow: 1;
  flex-basis: auto;
  box-sizing: border-box;
  background-color: #f4f4f4;
  justify-content: center;
  align-items: center;

  .actions {
    margin-bottom: 8px;
  }

  .ta_wrap {
    width: 100%;
    flex-shrink: 1;
    flex-grow: 1;
    flex-basis: auto;
    padding: 8px;
    box-sizing: border-box;

    #code_ta {
      width: 100%;
      height: 100%;
    }
  }
}
</style>
